getpid()
: Returns the process ID of the calling process.getppid()
: Returns the parent process ID of the calling process.#include <stdio.h>
#include <unistd.h>
int main() {
pid_t pid = getpid(); // Get current process ID
pid_t ppid = getppid(); // Get parent process ID
printf("PID: %d\n", pid);
printf("PPID: %d\n", ppid);
return 0;
}
getpid()
to retrieve the current process ID.getppid()
to retrieve the parent process ID.